<template>
    <div>
<h1>科室录入</h1>
<table class="table">
    <tbody>

<tr>
    <td>科室名称</td>
    <td>
        <input type="text" v-model="da.ksName">
    </td>
</tr>

<tr>
    <td>科室人数</td>
    <td>
        <input type="text" v-model="da.ksCount">
    </td>
</tr>

<tr>
    <td>科室描述</td>
    <td>
        <textarea  v-model="da.ksMiaoShu">

        </textarea>
        
    </td>
</tr>

<tr>
    <td></td>
    <td>
        <input type="button" value="添加" @click="add">
    </td>
</tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
const uc=useRouter()

const da=ref({
  "kId": 0,
  "ksName": "",
  "ksCount": 0,
  "ksMiaoShu": "",
  "ksCreateTime": "2025-05-19T03:23:08.235Z",

})

const add=()=>{
if(da.value.ksCount==null||da.value.ksMiaoShu==""||da.value.ksName==""){
    alert("不能为空");
    return
}


    axios.post("/api/KeShi/AddKs",da.value).then(res=>{
        if(res.data==-1){
            alert("科室已存在,不能重复");
            return
        }

        if(res.data>0){
            alert("添加成功");
            uc.push({path:'/showks'})
        }
        else{
            alert("添加成失败");
        }
    })
}
</script>

<style scoped>

</style>